# -*- coding: utf-8 -*-
"""
    :copyright: (c) 2019 by enjoyZHou on 2019-06-28
"""
import xlrd


def extract_file(file_path):
    data = {}

    wb = xlrd.open_workbook(filename=file_path)
    sheet_names = wb.sheet_names()

    def _read_rows(index, sheet=None):
        """ 读取文件的所有行
        :param index:
        :param sheet:
        :return:
        """
        sheet = sheet or wb.sheet_by_index(index)
        row_li = []
        for row_num in range(sheet.nrows):
            row_li.append(sheet.row_values(row_num))
        return row_li

    for index, name in enumerate(sheet_names):
        rows = _read_rows(index)
        data[name] = rows
    return data
